import {
  VuexModule,
  Module,
  Mutation,
  Action,
  getModule
} from 'vuex-module-decorators'

// import {
//   getSidebarStatus,
//   setSidebarStatus,
//   setLanguage
// } from '@/utils/cookies'

import store from '@/store'

// import { getLocale } from '@/lang'

export enum DeviceType {
  Mobile,
  Desktop
}

export interface IAppState {

  device: DeviceType
  sidebar: {
    opened: boolean
    withoutAnimation: boolean
  }
  // language: string,
  selectBar:number,
  selectBarS:any,
  moduleBar:number,
  router_cargo:any,   //铺货的路由传递数据
  router_pos:any ,     //商户的路由数据
  router_w:any,    //网点的路由数据
  
  shopInfo:any ,   //商户信息
  profitInfo:any   //商户分润
  staffInfo:any    //员工信息

  idenifyInfo:any ,   // 身份信息  支付宝信息

  myData:any,


  pedestalList:any,    //调拨底座的数量
  BankList:any,    //调拨充电宝的数量



}

@Module({ dynamic: true, store, name: 'app' })

class App extends VuexModule implements IAppState {

  public sidebar = {
    // opened: getSidebarStatus() !== 'closed',
    opened:true,
    withoutAnimation: false
  }
  public moduleBar=2   //统计的四种
  public device = DeviceType.Desktop
  public selectBar=0
  public selectBarS=''

  public router_cargo=''   //铺货的路由传递数据
  public router_pos='' //商户的路由数据
  public router_w=''   //网点的路由数据

  public shopInfo=''
  public profitInfo=''
  // public language = getLocale()

  public staffInfo=''


  public idenifyInfo={
  realName:'',
  blackAccountName:'',
  card:'',
  blackNum:'',
  }

  //支付链接
  public orderLink=''

    //页面缓存
  myData=''


  //
  public  pedestalList:any=[
    {
    id:99999
    }
  ]    //为啥要在这里定义！！！！！！！！！

  BankList:any=[
   {
    id:888888
    }
  ]



   @Mutation
  private SELECT_BAR(selectBar: number) {

     this.selectBar=selectBar
     
     console.log('this.selectBarVuex',this.selectBar)
    // this.sidebar.opened = !this.sidebar.opened
    // this.sidebar.withoutAnimation = withoutAnimation
    // if (this.sidebar.opened) {
    //   setSidebarStatus('opened')
    // } else {
    //   setSidebarStatus('closed')
    // }
  }
   @Mutation
  private SELECT_BARS(selectBarS:any) {

     this.selectBarS=selectBarS
     
     console.log('this.selectBarVuex',this.selectBarS)
    // this.sidebar.opened = !this.sidebar.opened
    // this.sidebar.withoutAnimation = withoutAnimation
    // if (this.sidebar.opened) {
    //   setSidebarStatus('opened')
    // } else {
    //   setSidebarStatus('closed')
    // }
  }
  
  @Mutation 
  private  SELECT_MODULE_BAR(selectModuleBar:number){

        this.moduleBar=selectModuleBar
        // console.log()
  }

  @Mutation 
  private  routerCargo(data:any){

      this.router_cargo=data

      console.log(this.router_cargo,'this.router_cargo铺货的路由传递数据')
  }

  @Mutation 
  private  routerCargoPos(data:any){

      // this.router_cargo=data
       this.router_pos=data //商户的路由数据

      console.log(this.router_cargo,'this.商户的路由数据')
  }

   @Mutation 
  private  routerW(data:any){

      // this.router_cargo=data
       this.router_w=data //网店的路由数据

      console.log(this.router_cargo,'this.网店的路由数据')
  }

   @Mutation 
  private  shopInfoM(data:any){

      // this.router_cargo=data

      this.shopInfo=data //网店的路由数据

      console.log(this.shopInfo,'this.商户信息')
  }

   @Mutation 
  private  profitInfoM(data:any){

      // this.router_cargo=data

      this.profitInfo=data //商户分润

      console.log(this.profitInfo,'this.商户分润')
  }

   @Mutation 
  private  staffInfoM(data:any){

      this.staffInfo=data //员工信息

      console.log(this.staffInfo,'员工信息')
  }

  @Mutation 
  private  idenifyInfoM(data:any){

      this.idenifyInfo=data 

      console.log(this.idenifyInfo,'1231231231231289893281938129312')
  }

  @Mutation 
  private  orderLinkM(data:any){

      this.orderLink=data

      console.log(this.orderLink,'orderLinkorderLinkorderLinkorderLink')
  }

  @Mutation 
  private  myDataM(data:any){

      this.myData=data

      console.log(this.myData,'this.myDatathis.myDatathis.myDatathis.myDatathis.myDatathis.myData')
  }

  @Mutation 
  private  pedestalListM(data:any){

      this.pedestalList=data

      setTimeout(()=>{

          console.log(this.pedestalList,'mutation-this.pedestalList')

      },2000)

      // console.log(this.myData,'this.myDatathis.myDatathis.myDatathis.myDatathis.myDatathis.myData')
  }

  @Mutation 
  private  BankListM(data:any){

      this.BankList=data

      setTimeout(()=>{

          console.log(this.BankList,'mutation')

      },2000)

      // console.log(this.myData,'this.myDatathis.myDatathis.myDatathis.myDatathis.myDatathis.myData')
  }

  

  


  

  

  

  

  

  

  

  
  // @Mutation
  // private TOGGLE_SIDEBAR(withoutAnimation: boolean) {
  //   // this.sidebar.opened = !this.sidebar.opened
  //   // this.sidebar.withoutAnimation = withoutAnimation
  //   // if (this.sidebar.opened) {
  //   //   setSidebarStatus('opened')
  //   // } else {
  //   //   setSidebarStatus('closed')
  //   // }
  // }



  // 首页 topbar
  @Action
  public selectBarAction(selectBar: number) {
    this.SELECT_BAR(selectBar)
  }

  // topbar
  @Action
  public selectBarSAction(selectBarS: number) {
    this.SELECT_BARS(selectBarS)
  }

  // 统计  总数据 收益 交易 商户
  @Action
  public selectModuleBarAction(selectModuleBar: number) {
    this.SELECT_MODULE_BAR(selectModuleBar)
  }

   @Action
  public routerCargoAction(data:any) {
    this.routerCargo(data)
  }

  @Action
  public routerCargoPosAction(data:any) {
        this.routerCargoPos(data)
  }

    @Action
  public routerWAction(data:any) {
        this.routerW(data)

  }


    @Action
  public shopInfoAction(data:any) {
        this.shopInfoM(data)

  }
  
   @Action
  public profitInfoAction(data:any) {
        this.profitInfoM(data)

  }

   @Action
  public staffInfoAction(data:any) {
        this.staffInfoM(data)

  }

   @Action
  public idenifyInfoAction(data:any) {
        this.idenifyInfoM(data)

  }

  @Action
  public orderLinkAction(data:any) {
        this.orderLinkM(data)

  }


   @Action
  public myDataAction(data:any) {
        this.myDataM(data)

  }

   @Action
  public pedestalListAction(data:any) {


      console.log(data,'pedestalListAction数据')

        //  this.pedestalList=data

      // data.filter((item:any,index:any)=>{

      //       this.pedestalList.push(item)

          
          
      // })
           setTimeout(()=>{
      
          console.log(this.pedestalList)
          },2000)

         this.pedestalListM(data)

  }
   @Action
  public BankListAction(data:any) {
      console.log(data,'BankListBankListMBankListMBankListMBankListM123')

           setTimeout(()=>{
      
          console.log(this.pedestalList)
          },2000)

         this.BankListM(data)

  }

  

  

  

  

  


}

export const AppModule = getModule(App)
